s = "rat", t = "car"

var isAnagram = function (s, t) {
    if (s.length !== t.length) {
        return false
    }
    let obj = {}
    for (let i = 0; i < s.length; i++) {
        if (!obj[s[i]]) {
            let a = s.split(s[i]).length - 1
            if (t.indexOf(s[i]) === -1) {
                return false
            }
            let b = t.split(s[i]).length - 1
            if (a !== b) {
                return false
            }
            obj[s[i]] = s[i]
        }
    }
    return true
};
console.log(isAnagram(s, t));


